import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'


// import { viteMockServe } from 'vite-plugin-mock'

// https://vitejs.dev/config/
export default defineConfig({
  base: "/meeting-rj-web/",
  plugins: [
    vue(),
    vueJsx(),

    // mock 假数据
    // viteMockServe({
    //   mockPath: "./src/mock/", // 解析，路径可根据实际变动
    //   localEnabled: true, // 此处可以手动设置为true，也可以根据官方文档格式
    //   supportTs: false,
    //   logger: true
  
    // })

  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      // "@asset": path.resolve(__dirname, "./src/assets"),
      //       "@svg": path.resolve(__dirname, "./src/assets/svg"),
      //       "@plugin": path.resolve(__dirname, "./src/plugins"),
            // "@view": path.resolve(__dirname, "./src/views"),
            // "@component": path.resolve(__dirname, "./src/components"),
            // "@store": path.resolve(__dirname, "./src/pinia_stores"),
            // "@publishEditor": path.resolve(__dirname, "./src/components/low_code/page_editor"),
            // "@publishPage": path.resolve(__dirname, "./src/components/low_code/page_publish"),
    }
  },
  lintOnSave: false,
  // server:{
  //   hmr:{overlay: false}
  // },
  // vue.config.js
  
  server: {
    proxy: {
      '/sweet-api': {
        // target: 'http://39.105.179.38:8080', // 指定代理服务器
        target: 'http://10.31.206.235:8080', // 指定代理服务器
        // target: 'https://d-nari-test.sgepri.sgcc.com.cn/meeting-rj-service',   // 指定代理服务器
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/sweet-api/, '')
      },
       // 将上传文件的请求转发到Minio服务器  
      '/express-api': {  
        target: 'http://127.0.0.1:3000', 
        changeOrigin: true, 
        rewrite: (path) => path.replace(/^\/express-api/, '') 
      }  
    }
  }
})


